package views;

import com.sun.awt.AWTUtilities;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Shape;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.text.ParseException;

import javax.imageio.ImageIO;
import javax.swing.*;

public class SplashFrame extends JWindow {

	

	public SplashFrame() {

            try{
		setLayout(new GridBagLayout());
                AWTUtilities.setWindowOpaque(SplashFrame.this,false);
		ImageIcon bgImage = new ImageIcon(ImageIO.read(getClass().getResource("/resources/img/yourJavaLogoSplash.png")));
		JLabel splash = new JLabel(bgImage);
		this.setBackground(Color.WHITE);

		int width = 250; // 590 x   347
                int height = 250;

                int x = (Toolkit.getDefaultToolkit().getScreenSize().width - width) / 2;
                int y = (Toolkit.getDefaultToolkit().getScreenSize().height - height) / 2;
                setVisible(true);
                    setBounds(x, y, width, height);

                   
                GridBagConstraints gbc = new GridBagConstraints();

                gbc.fill = GridBagConstraints.HORIZONTAL;
                gbc.gridx = 0;
                gbc.gridy = 0;
                this.add(splash,gbc);


                gbc.fill = GridBagConstraints.HORIZONTAL;
                gbc.gridx = 0;
                gbc.gridy = 1;

              
                setVisible(true);
                
                current();
                
            }catch(Exception e){
                
                
            }

  }

  public int current(){
 	  int i = 0;
	  for (i = 0 ; i <= 100; i++){
		  i = i + 20;
		 

		  try {
			Thread.sleep(600);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	  }
	  if (i >= 100){
		  this.dispose();
	  }
	  return i;
  }

}